﻿CloudDisk.Admin.ProfilePanel = (function(cfg){
    var el = $('#profilePanel');

    return {
	    activate: function(){
		    var that = this;
		    el.show();
			CloudDisk.Admin.SessionMgr.querySpaceInfo(function(data){
			    var d = [];
				//for(var k in data.result){
				    d.push({
					   name: data.result.user_name,
					   y: parseFloat(data.result.used_space)
					});
					
				//}
				
				d.push({
				   name: '可用空间',
				   y: parseFloat(data.result.total_space) - parseFloat(data.result.used_space)
				});
				
				that.drawChart(d);
				//d.push()
			});
		},
		
		drawChart: function(data){
			$('#profilePanel .adm-profile-chart').highcharts({
				chart: {
					plotBackgroundColor: null,
					plotBorderWidth: null,
					plotShadow: false
				},
				title: {
					text: '空间使用统计'
				},
				tooltip: {
					//pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
					pointFormat: '{series.name}: <b>{point.y}GB</b>'
				},
				plotOptions: {
					pie: {
						allowPointSelect: true,
						cursor: 'pointer',
						dataLabels: {
							enabled: false
						},
						showInLegend: true
					}
				},
				series: [{
					type: 'pie',
					name: '',
					data: data
				}]
			});		
		}
	};
})();